#pragma once
#include "Agent.h"
#include <vector>
//#include "../SGD Wrappers/SGD_Event.h"
struct ThreatTable
{
	// Current Target
	Entity* Target = nullptr;

	// Array of all players on map
	Entity* OtherPlayers;
	int* OtherThreat;
};

class CAI :
	public CAgent
{
public:
	enum State{IDLE_STATE, PATROL_STATE, CHASE_STATE, ATTACK_STATE, RETURN_STATE};
	
	CAI();
	~CAI();
	void Update(float elapsedTime) override;

	void SwitchStates(State newState) { m_CurrState = newState; }

	virtual void HandleCollision(const Entity* pOther) override;

	// States
	void IdleState();
	void PatrolState();
	void ChaseState();
	void ReturnState();
	void AttackState();

	//  Mutators
	void SetHomePos(SGD::Point homePos) { m_ptHomePos = homePos; }
	void SetTarget(Entity* target) { m_tTable.Target = target; }
	void AddWaypoints(SGD::Point wayPoint)	{ m_ptWayPoints.push_back(wayPoint); }

	// Accessors
	SGD::Point GetHomePos()const { return m_ptHomePos; }
	Entity* GetTarget()const { return m_tTable.Target; }

protected:
	State					m_CurrState = IDLE_STATE;
	unsigned int			m_nCurrWaypoint;
	std::vector<SGD::Point>	m_ptWayPoints;
	SGD::Point				m_ptHomePos;
	int						m_fAttackRadius = 400;
	float					m_fAttackTimer;
	float					m_fDefAttack;
	float					m_fDamage = 10;
	ThreatTable				m_tTable;
	bool					m_bSuddenDeath;
	bool					m_bInRange = false;
	bool					m_bPathFinding = false;
};

